<?php
/**
* webappkit core initialization.
* include this file before using any webappkit package (kits)
*
* This file belongs to the core webappkit package (kit)
* @link http://webappkit.net
* @package webappkit
* @author J.Ducastel <nospam0@ducastel.name>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

/**
* to be included once
*/
if (defined('WAK_ROOT_PATH'))
    return;

/**
* define WAK_START_TIME (microtime)
*/
list($usec, $sec) = explode(" ", microtime());
$microtime=((float)$usec + (float)$sec);
if (!defined('WAK_START_TIME'))
    define('WAK_START_TIME',$microtime);

// defining kits root
// this file should right at the webappkit root
define('WAK_ROOT_PATH',realpath(dirname(__FILE__)).'/');
// echo WEBAPPKIT_ROOT_PATH;

// getting core libraries
switch (substr(phpversion(),0,1)) {
    case '4':
        // running php4
        include('webappkit.wak/core.wak/lib/webappkit.class.php4');
        include('webappkit.wak/core.wak/lib/wakkit.class.php4');
        include('webappkit.wak/core.wak/lib/waktool.class.php4');
        break;
    case '5':
        include('webappkit.wak/core.wak/lib/interfaces.php5');
        include('webappkit.wak/core.wak/lib/exceptions.php5');
        include('webappkit.wak/core.wak/lib/webappkit.class.php5');
        include('webappkit.wak/core.wak/lib/wakkitcfg.class.php5');
        include('webappkit.wak/core.wak/lib/wakkit.class.php5');
        include('webappkit.wak/core.wak/lib/waktool.class.php5');
        //include('wakstorage.class.php4');
        break;
    default:
        trigger_error("unsupported php version ".phpversion(),E_USER_ERROR);
}

/**
 * auto-loading of indexed classes
 * @param string $class class name
 */
if (function_exists('spl_autoload_register')) {
    spl_autoload_register(array('Webappkit','loadClass'));
} else {
    function __autoload($class) {
        return Webappkit::loadClass($class);
    }
}

// print_r(spl_autoload_functions());
